package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 字典子项
 */

/**
 * @author xuchang
 */
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Data
@Table(name = "t_it_dict", uniqueConstraints = {@UniqueConstraint(columnNames={"dict_entry", "dict_subentry", "parent_value"})})
public class ItDict implements Serializable {
    private static final long serialVersionUID = -8017207561486280051L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "zd_id")
    private Integer zdId;

    @ApiModelProperty(value = "字典大类id")
    @Column(name = "dict_entry")
    private String dictEntry;

    @ApiModelProperty(value = "字典子项值（相当于value）")
    @Column(name = "dict_subentry")
    private String dictSubentry;

    @ApiModelProperty(value = "字典子项名（相当于label）")
    @Column(name = "dict_value")
    private String dictValue;

    @ApiModelProperty(value = "关联的父级字典的值")
    @Column(name = "parent_value")
    private String parentValue;

    @Column(name = "seq")
    @ApiModelProperty(value = "字典项序号")
    @JsonIgnoreProperties(ignoreUnknown = true) /*解决部分字段redis中的json与当前实体对象定义不一致，这里忽略不存在的属性*/
    private Integer seq;

//    改造后暂时废弃
    @JsonIgnore
    @Deprecated
    @Column(name = "dict_key")
    private Integer dictKey;

    public ItDict(String dictSubentry, String dictValue){
        this.dictSubentry = dictSubentry;
        this.dictValue  = dictValue;
//        this.dictEntry = dictEntry;
    }
    public ItDict(Integer zdId, String dictSubentry, String dictValue){
        this.zdId = zdId;
        this.dictSubentry = dictSubentry;
        this.dictValue  = dictValue;
//        this.dictEntry = dictEntry;
    }
}
